package com.lzc.blog.controller;

import com.lzc.blog.service.CommentsService;
import com.lzc.blog.vo.Result;
import com.lzc.blog.vo.params.CommentParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文章评论
 */
@RestController
@RequestMapping("/comments")
public class CommentController {
    @Autowired
    private CommentsService commentsService;

    /**
     * 显示评论
     * @param id
     * @return
     */
    @GetMapping("/article/{id}")
    public Result  comments(@PathVariable("id") Long id){

        return commentsService.commentsByArticleId(id);
    }

    /**
     * 写评论
     * @param commentParam
     * @return
     */
    @PostMapping("/create/change")
    public Result comment(@RequestBody CommentParam commentParam){
        return commentsService.comment(commentParam);
    }
}
